package com.zzg.springboot.entity;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

public class SecurityUserEntity extends UserEntity implements UserDetails {

	public SecurityUserEntity(UserEntity suser) {
		if (suser != null)
		{
			this.setId(suser.getId());
			this.setName(suser.getName());
			this.setPwd(suser.getPwd());
		}

	}

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		// TODO Auto-generated method stub
		 Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
		 SimpleGrantedAuthority authority = new SimpleGrantedAuthority("ROLE_ADMIN"); //手动设置超级管理员
		 authorities.add(authority);
		 return authorities;
	}

	@Override
	public String getPassword() {
		// TODO Auto-generated method stub
		return super.getPwd();
	}

	@Override
	public String getUsername() {
		// TODO Auto-generated method stub
		return super.getName();
	}

	@Override
	public boolean isAccountNonExpired() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isEnabled() {
		// TODO Auto-generated method stub
		return true;
	}

}
